blog

Home / DeveloperSection / Blogs / Record insert and retrieve using sqlite database in nodejs in Windows OS 64

Record insert and retrieve using sqlite database in nodejs in Windows OS 64

Anonymous User7207 25-Jan-2014

In this blog, I’m explaining  record insert and retrieve  using sqlite database in nodejs.

1.       DataBaseConnection.js file

var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('databases/users');
db.serialize(function () {
    db.run("CREATE TABLE NodeJs (Name TEXT,EmailID TEXT,City TEXT)");
    var stmt = db.prepare("INSERT INTO NodeJs VALUES (?,?,?)");
        stmt.run("Kamlakar Singh","kamlakarsingh4@gmail.com","Allahabad");
    stmt.finalize();
    db.each("SELECT rowid AS id, Name,EmailID,City FROM NodeJs", function (err, row) {
        console.log(row.id + ": " + row.Name+" : "+row.EmailID+" : "+row.City);
    });
});
db.close();

    2. Open command prompt and go to your file location your project. 

3. Install sqlite3 like this.

       Npm install sqlite3.

4.       Execute your  file like thisRecord insert and retrieve using sqlite database in nodejs in Windows OS 64

5.       Record insert and retrieve successfully .

in my next post i'll explain about Javascript framework and library


Updated 18-Sep-2014
I am a content writter !

Leave Comment

Comments

Liked By